Create Complex Cursor Shortcuts to Run Commands and Generate AI Commits

Manually staging files, writing commit messages, committing, and syncing to Git involves multiple repetitive steps. This lesson demonstrates how to significantly streamline this common Git workflow in Cursor (or VS Code) by creating a single, powerful keyboard shortcut using keybindings.json and the runCommands feature.

Workflow demonstrated in this lesson:

  • Open keybindings.json to customize keyboard shortcuts.
  • Unbind default shortcuts (like Shift+Cmd+S) that you might not use.
  • Utilize the runCommands command to create a sequence of actions.
  • Chain together git.stageAll, cursor.generateGitCommitMessage, git.commitAll, and git.sync commands.
  • Bind this entire sequence to a single custom keyboard shortcut.
  • Execute the full stage -> AI commit message -> commit -> sync workflow with one keystroke.

Key benefits:

  • Combines multiple Git actions into one efficient step.
  • Automates staging, committing, and syncing changes.
  • Leverages Cursor's AI to generate commit messages automatically.
  • Frees up valuable keyboard shortcuts for powerful custom workflows.
  • Significantly speeds up your development cycle by reducing manual Git operations.
{ "key": "shift+cmd+s", "command": "runCommands", "args": { "commands": [ { "command": "git.stageAll" }, { "command": "cursor.generateGitCommitMessage" }, { "command": "git.commitAll" }, { "command": "git.sync" } ] } }, { "key": "shift+cmd+s", "command": "-workbench.action.files.saveAs" }, { "key": "shift+cmd+s", "command": "-workbench.action.files.saveLocalFile", "when": "remoteFileDialogVisible" }
Share with a coworker

Transcript

[00:00] We have a folder we initialized with git, which has an unstaged gitignore, and an empty repository on github. So hit command shift p, we're going to type in shortcuts, and make sure to select the open keyboard shortcuts json version. I'm going to scroll down to the bottom. I'm going to add a comma and paste in a snippet which I'll explain. These two definitions are just removing the default assignments for command shift s.

[00:24] You can see by the minus here that we're unbinding these ones. I don't think I've ever used file save as in a code editor in my life, and instead I'm going to bind command shift s up here to the command run commands. And then this takes args with a sequence of commands. The sequence we're going to give it is to stage everything in git, then use cursor to generate a commit message, then commit everything, and then to push and pull. Once I save this file all I have to do is hit command shift S.

[00:54] You see it staged it, it generated a commit message, it pushed it, and if I refresh over here We now have our gitignore up on GitHub. So let's say I want to take some notes. We'll create a new file. I use an extension called advanced new file. We'll select the workspace root for a file named notes.md.

[01:11] I can dictate, I'm just learning about complex shortcuts and cursor. Make sure I save that and then hit command shift s. You'll get a pop-up saying it'll pull and push and since this is just going to be markdown files in this repo I'm going to say okay don't show again and I'll add another line. This is a super powerful feature for combining many things that cursor can do. Paste that in, save, command shift S.

[01:34] I let my dictation run for a bit too long I'll delete this, hit command shift S. And you can see that every step along the way in our commit history we're getting these added gitignore, added notes.md, updated notes.md with insights, and removed lines from notes.md, and in our repo we have everything automatically synced and saved. Now I'll leave this up to you to determine if it's appropriate to auto-stage, auto-commit, auto-push, based on whatever your project is.